import { defineStore } from "pinia";

export const usePinia = defineStore("storeID", {
  // 状态数据
  state: () => {
    return {
      pinia_counter: 0,
      pinia_name: "张三",
    };
  },
  //   计算属性
  getters: {
    change_pinia_counter() {
      // 缓存机制，多次调用相同值只计算一次
      console.log("getters");
      return this.pinia_counter + 10;
    },
  },
  //   操作方法
  actions: {
    update_counter(val) {
      this.pinia_counter += val;
    },
  },
});
